package com.riant.test3;

import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

public class RestTEmplateUtils {

    //自创建RestTemplate
    public static RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(30000);// 设置连接超时，单位毫秒
        requestFactory.setReadTimeout(30000);  //设置读取超时
        RestTemplate restTemplate = new RestTemplate();
        System.out.println(restTemplate.getRequestFactory());
        restTemplate.setRequestFactory(requestFactory);

        return restTemplate;
    }

}
